import { useEffect } from 'react';
import { eventBus } from '@/lib/event';
import { EditorStore } from '../editorStore';
import { FocusEditorFixMobile, HandleFileType } from '../editorUtils';
import { BlinkoStore } from '@/store/blinkoStore';
import { OnSendContentType } from '../type';
import Vditor from 'vditor';
import { ToolbarMobile, ToolbarPC } from '../EditorToolbar';
import { RootStore } from '@/store';
import { UserStore } from '@/store/user';
import { i18nEditor } from '../EditorToolbar/i18n';
import { useTranslation } from 'react-i18next';
import { useMediaQuery } from 'usehooks-ts';
import { AIExtend, Extend } from '../EditorToolbar/extends';
import { NoteType, toNoteTypeEnum } from '@shared/lib/types';
import { api } from '@/lib/trpc';
import { useNavigate, useSearchParams } from 'react-router-dom';
import { getBlinkoEndpoint } from '@/lib/blinkoEndpoint';

export const useEditorInit = (
  store: EditorStore,
  onChange: ((content: string) => void) | undefined,
  onSend: (args: OnSendContentType) => Promise<any>,
  mode: 'create' | 'edit' | 'comment',
  originReference: number[] = [],
  content: string
) => {
  const { t } = useTranslation()
  const isPc = useMediaQuery('(min-width: 768px)')
  const blinko = RootStore.Get(BlinkoStore)
  const navigate = useNavigate()
  const [searchParams] = useSearchParams()

  useEffect(() => {
    const showToolbar = store.isShowEditorToolbar(isPc)
    if (store.vditor) {
      store.vditor?.destroy();
      store.vditor = null
    }

    // Insert Vditor icons script
    if (!document.getElementById('vditor-icons-injected')) {
      const script = document.createElement('script');
      script.id = 'vditor-icons-injected';
      script.innerHTML = `
        if (!document.getElementById('vditor-icons-svg')) {
          document.body.insertAdjacentHTML('afterBegin', \`
            <svg id="vditor-icons-svg" style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="http://www.w3.org/2000/svg">
              <defs>
              <symbol id="vditor-icon-code-theme" viewBox="0 0 32 32">
                <path d="M25.785 24.935c1.681 0 3.054-1.392 3.054-3.096 0-2.058-3.054-5.416-3.054-5.416s-3.054 3.358-3.054 5.416c0 1.704 1.373 3.096 3.054 3.096zM11.28 23.239c0.273 0.273 0.715 0.273 0.985 0l9.851-9.847c0.273-0.273 0.273-0.715 0-0.985l-9.847-9.847c-0.023-0.023-0.050-0.046-0.077-0.065l-3.008-3.008c-0.063-0.062-0.15-0.101-0.246-0.101s-0.183 0.039-0.246 0.101l-1.846 1.846c-0.062 0.063-0.101 0.15-0.101 0.246s0.039 0.183 0.101 0.246l2.585 2.585-7.993 7.997c-0.273 0.273-0.273 0.715 0 0.985l9.843 9.847zM11.777 5.984l6.881 6.881h-13.759l6.878-6.881zM31.078 27.693h-30.157c-0.169 0-0.308 0.138-0.308 0.308v3.077c0 0.169 0.138 0.308 0.308 0.308h30.157c0.169 0 0.308-0.138 0.308-0.308v-3.077c0-0.169-0.138-0.308-0.308-0.308z"></path>
              </symbol>
              <symbol id="vditor-icon-quote" viewBox="0 0 32 32">
                <path d="M31.452 15.517l-30.82-15.452c-0.125-0.063-0.269-0.077-0.405-0.044-0.313 0.077-0.508 0.394-0.431 0.711l3.176 12.976c0.048 0.195 0.192 0.354 0.383 0.416l5.442 1.868-5.438 1.868c-0.192 0.066-0.335 0.221-0.38 0.416l-3.183 12.995c-0.033 0.136-0.018 0.28 0.044 0.402 0.144 0.291 0.497 0.409 0.792 0.265l30.82-15.364c0.114-0.055 0.206-0.151 0.265-0.262 0.144-0.295 0.026-0.648-0.265-0.796zM3.429 27.58l1.853-7.575 10.876-3.732c0.085-0.029 0.155-0.096 0.184-0.184 0.052-0.155-0.029-0.321-0.184-0.376l-10.876-3.729-1.846-7.546 23.138 11.602-23.145 11.54z"></path>
              </symbol>
              <symbol id="vditor-icon-after" viewBox="0 0 32 32">
                <path d="M31.636 28.045h-31.272c-0.202 0-0.364 0.162-0.364 0.36v2.697c0 0.198 0.162 0.36 0.364 0.36h31.272c0.202 0 0.364-0.162 0.364-0.36v-2.697c0-0.198-0.162-0.36-0.364-0.36zM15.717 23.056c0.066 0.084 0.169 0.138 0.283 0.138s0.217-0.054 0.283-0.137l0.001-0.001 5.034-6.369c0.184-0.234 0.018-0.58-0.283-0.58h-3.33v-15.209c0-0.198-0.162-0.36-0.36-0.36h-2.697c-0.198 0-0.36 0.162-0.36 0.36v15.204h-3.321c-0.301 0-0.467 0.346-0.283 0.58l5.034 6.373z"></path>
              </symbol>
              <symbol id="vditor-icon-before" viewBox="0 0 32 32">
                <path d="M31.636 0.539h-31.272c-0.202 0-0.364 0.162-0.364 0.36v2.697c0 0.198 0.162 0.36 0.364 0.36h31.272c0.202 0 0.364-0.162 0.364-0.36v-2.697c0-0.198-0.162-0.36-0.364-0.36zM16.283 8.944c-0.066-0.084-0.169-0.138-0.283-0.138s-0.217 0.054-0.283 0.137l-0.001 0.001-5.034 6.369c-0.048 0.060-0.076 0.137-0.076 0.221 0 0.198 0.161 0.359 0.359 0.359 0 0 0.001 0 0.001 0h3.321v15.209c0 0.198 0.162 0.36 0.36 0.36h2.697c0.198 0 0.36-0.162 0.36-0.36v-15.204h3.33c0.301 0 0.467-0.346 0.283-0.58l-5.034-6.373z"></path>
              </symbol>
              <symbol id="vditor-icon-headings" viewBox="0 0 32 32">
                <path d="M8.889 14.222h14.222v-12.444c0-0.982 0.796-1.778 1.778-1.778s1.778 0.796 1.778 1.778v0 28.444c0 0.982-0.796 1.778-1.778 1.778s-1.778-0.796-1.778-1.778v0-12.444h-14.222v12.444c0 0.982-0.796 1.778-1.778 1.778s-1.778-0.796-1.778-1.778v0-28.444c0-0.982 0.796-1.778 1.778-1.778s1.778 0.796 1.778 1.778v0z"></path>
              </symbol>
              <symbol id="vditor-icon-line" viewBox="0 0 32 32">
                <path d="M31.68 14.56h-31.36c-0.176 0-0.32 0.144-0.32 0.32v2.24c0 0.176 0.144 0.32 0.32 0.32h31.36c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32z"></path>
              </symbol>
              <symbol id="vditor-icon-code" viewBox="0 0 32 32">
                <path d="M31.862 16.604c0.27-0.583 0.144-1.297-0.358-1.749l-6.422-5.782c-0.617-0.555-1.567-0.506-2.122 0.111s-0.506 1.567 0.111 2.122l5.206 4.688-5.237 4.716c-0.617 0.555-0.667 1.506-0.111 2.122s1.506 0.667 2.122 0.111l6.422-5.782c0.177-0.159 0.307-0.351 0.39-0.557zM3.725 15.981l5.206-4.688c0.617-0.555 0.667-1.506 0.111-2.122s-1.506-0.667-2.122-0.111l-6.422 5.782c-0.502 0.452-0.629 1.166-0.358 1.749 0.083 0.207 0.213 0.398 0.39 0.557l6.422 5.782c0.617 0.555 1.567 0.506 2.122-0.111s0.506-1.567-0.111-2.122l-5.237-4.716zM20.305 4.173c0.78 0.284 1.182 1.146 0.898 1.926l-7.581 20.83c-0.284 0.78-1.146 1.182-1.926 0.898s-1.182-1.146-0.898-1.926l7.581-20.83c0.284-0.78 1.146-1.182 1.926-0.898z"></path>
              </symbol>
              <symbol id="vditor-icon-inline-code" viewBox="0 0 32 32">
                <path d="M31.862 16.604c0.27-0.583 0.144-1.297-0.358-1.749l-6.422-5.782c-0.617-0.555-1.567-0.506-2.122 0.111v0 0c-0.555 0.617-0.506 1.567 0.111 2.122l5.206 4.688-5.237 4.716c-0.617 0.555-0.667 1.506-0.111 2.122s1.506 0.667 2.122 0.111l6.422-5.782c0.177-0.159 0.307-0.351 0.39-0.557zM3.725 15.981l5.206-4.688c0.617-0.555 0.667-1.506 0.111-2.122v0 0c-0.555-0.617-1.506-0.667-2.122-0.111v0l-6.422 5.782c-0.502 0.452-0.629 1.166-0.358 1.749 0.083 0.207 0.213 0.398 0.39 0.557l6.422 5.782c0.617 0.555 1.567 0.506 2.122-0.111s0.506-1.567-0.111-2.122l-5.237-4.716z"></path>
              </symbol>
              <symbol id="vditor-icon-both" viewBox="0 0 32 32">
                <path d="M31.858 22.232l-0.007-0.007c-1.575-3.332-4.014-5.047-7.261-5.047s-5.686 1.718-7.265 5.047v0.004c-0.193 0.411-0.193 0.889 0 1.3 1.579 3.329 4.018 5.043 7.265 5.043s5.686-1.718 7.265-5.047c0.193-0.411 0.193-0.886 0.004-1.293zM24.59 26.286c-2.218 0-3.836-1.071-5.040-3.411 1.2-2.339 2.822-3.411 5.040-3.411s3.836 1.071 5.040 3.411c-1.2 2.339-2.822 3.411-5.040 3.411z"></path>
                <path d="M22.607 22.893c0 1.105 0.895 2 2 2s2-0.895 2-2v0c0-1.105-0.895-2-2-2s-2 0.895-2 2v0z"></path>
                <path d="M2.571 6h25.144v9.036h2.572v-10.465c0-0.632-0.511-1.143-1.143-1.143h-28.001c-0.632 0-1.143 0.511-1.143 1.143v18.572c0 0.632 0.511 1.143 1.143 1.143h12.572v-2.572h-11.143v-15.715z"></path>
                <path d="M23.604 9.789l-1.314-1.314c-0.111-0.111-0.293-0.111-0.404 0l-6.565 6.572-3.075-3.079c-0.111-0.111-0.293-0.111-0.404 0l-5.154 5.154c-0.111 0.111-0.111 0.293 0 0.404l1.314 1.314c0.111 0.111 0.293 0.111 0.404 0l3.636-3.636 3.075 3.079c0.111 0.111 0.293 0.111 0.404 0l8.082-8.090c0.114-0.111 0.114-0.293 0-0.404z"></path>
              </symbol>
              <symbol id="vditor-icon-theme" viewBox="0 0 32 32">
                <path d="M30.249 0.637h-8.207c-0.693 0-1.309 0.474-1.473 1.166-0.497 2.102-2.38 3.61-4.569 3.61s-4.072-1.508-4.569-3.61c-0.161-0.673-0.758-1.166-1.47-1.166-0.001 0-0.002 0-0.003 0h-8.207c-0.967 0-1.751 0.784-1.751 1.751v0 10.030c0 0.967 0.784 1.751 1.751 1.751v0h2.985v15.443c0 0.967 0.784 1.751 1.751 1.751v0h19.025c0.967 0 1.751-0.784 1.751-1.751v0-15.443h2.985c0.967 0 1.751-0.784 1.751-1.751v0-10.030c0-0.967-0.784-1.751-1.751-1.751v0zM29.134 11.303h-4.736v17.194h-16.796v-17.194h-4.736v-7.801h6.101c1.122 2.834 3.881 4.776 7.033 4.776s5.91-1.942 7.033-4.776h6.102v7.801z"></path>
              </symbol>
              <symbol id="vditor-icon-resize" viewBox="0 0 128 32">
                <path d="M1.28 0c-0.704 0-1.28 0.163-1.28 0.365 0 0.291 0 2.618 0 2.909 0 0.198 0.576 0.362 1.28 0.362 12.544 0 112.896 0 125.44 0 0.704 0 1.28-0.163 1.28-0.362 0-0.291 0-2.618 0-2.909 0-0.202-0.576-0.365-1.28-0.365-25.088 0-112.896 0-125.44 0zM1.28 28.365c-0.704 0-1.28 0.163-1.28 0.362 0 0.291 0 2.618 0 2.909 0 0.202 0.576 0.365 1.28 0.365 12.544 0 112.896 0 125.44 0 0.704 0 1.28-0.163 1.28-0.365 0-0.291 0-2.618 0-2.909 0-0.198-0.576-0.362-1.28-0.362-25.088 0-112.896 0-125.44 0zM1.28 14.182c-0.704 0-1.28 0.163-1.28 0.362 0 0.291 0 2.621 0 2.912 0 0.198 0.576 0.362 1.28 0.362 12.544 0 112.896 0 125.44 0 0.704 0 1.28-0.163 1.28-0.362 0-0.291 0-2.621 0-2.912 0-0.198-0.576-0.362-1.28-0.362-25.088 0-112.896 0-125.44 0z"></path>
              </symbol>
              <symbol id="vditor-icon-export" viewBox="0 0 32 32">
                <path d="M31.399 26.042h-2.202c-0.172 0-0.315 0.143-0.315 0.315v2.529h-25.769v-25.773h25.773v2.529c0 0.172 0.143 0.315 0.315 0.315h2.202c0.172 0 0.315-0.139 0.315-0.315v-4.1c0-0.696-0.561-1.256-1.256-1.256h-28.92c-0.696 0-1.256 0.561-1.256 1.256v28.916c0 0.696 0.561 1.256 1.256 1.256h28.916c0.696 0 1.256-0.561 1.256-1.256v-4.1c0-0.176-0.143-0.315-0.315-0.315zM32.16 15.742l-5.807-4.583c-0.217-0.172-0.532-0.016-0.532 0.258v3.11h-12.85c-0.18 0-0.327 0.147-0.327 0.327v2.292c0 0.18 0.147 0.327 0.327 0.327h12.85v3.11c0 0.274 0.319 0.43 0.532 0.258l5.807-4.583c0.077-0.060 0.126-0.153 0.126-0.258s-0.049-0.197-0.125-0.257l-0.001-0.001z"></path>
              </symbol>
              <symbol id="vditor-icon-copy" viewBox="0 0 32 32">
                <path d="M27.429 0h-19.143c-0.157 0-0.286 0.129-0.286 0.286v2c0 0.157 0.129 0.286 0.286 0.286h17.714v24.571c0 0.157 0.129 0.286 0.286 0.286h2c0.157 0 0.286-0.129 0.286-0.286v-26c0-0.632-0.511-1.143-1.143-1.143zM22.857 4.571h-18.286c-0.632 0-1.143 0.511-1.143 1.143v18.954c0 0.304 0.121 0.593 0.336 0.807l6.189 6.189c0.079 0.079 0.168 0.143 0.264 0.196v0.068h0.15c0.125 0.046 0.257 0.071 0.393 0.071h12.096c0.632 0 1.143-0.511 1.143-1.143v-25.143c0-0.632-0.511-1.143-1.143-1.143zM10.214 28.293l-3.075-3.079h3.075v3.079zM21.429 29.429h-8.929v-5.071c0-0.789-0.639-1.429-1.429-1.429h-5.071v-15.786h15.429v22.286z"></path>
              </symbol>
              <symbol id="vditor-icon-pause" viewBox="0 0 32 32">
                <path d="M6.095 0h3.81v32h-3.81zM25.524 0h-3.048c-0.21 0-0.381 0.171-0.381 0.381v31.238c0 0.21 0.171 0.381 0.381 0.381h3.048c0.21 0 0.381-0.171 0.381-0.381v-31.238c0-0.21-0.171-0.381-0.381-0.381z"></path>
              </symbol>
              <symbol id="vditor-icon-preview" viewBox="0 0 32 32">
                <path d="M31.788 15.053c-3.479-7.329-8.738-11.017-15.788-11.017-7.054 0-12.309 3.688-15.788 11.021-0.134 0.277-0.212 0.602-0.212 0.945s0.078 0.668 0.218 0.958l-0.006-0.013c3.479 7.329 8.738 11.017 15.788 11.017 7.054 0 12.309-3.688 15.788-11.021 0.283-0.595 0.283-1.284 0-1.89zM16 25.322c-5.92 0-10.254-3.002-13.311-9.322 3.057-6.32 7.391-9.322 13.311-9.322s10.254 3.002 13.311 9.322c-3.053 6.32-7.388 9.322-13.311 9.322zM15.853 9.541c-3.567 0-6.459 2.892-6.459 6.459s2.892 6.459 6.459 6.459 6.459-2.892 6.459-6.459-2.892-6.459-6.459-6.459zM15.853 20.11c-2.272 0-4.11-1.839-4.11-4.11s1.839-4.11 4.11-4.11 4.11 1.839 4.11 4.11-1.839 4.11-4.11 4.11z"></path>
              </symbol>
              <symbol id="vditor-icon-edit" viewBox="0 0 32 32">
                <path d="M31.68 16h-2.24c-0.176 0-0.32 0.144-0.32 0.32v12.8h-26.239v-26.239h12.8c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32h-14.4c-0.708 0-1.28 0.572-1.28 1.28v29.439c0 0.708 0.572 1.28 1.28 1.28h29.439c0.708 0 1.28-0.572 1.28-1.28v-14.4c0-0.176-0.144-0.32-0.32-0.32z"></path>
                <path d="M9.756 16.916l-0.076 4.756c-0.004 0.356 0.284 0.648 0.64 0.648h0.016l4.72-0.116c0.080-0.004 0.16-0.036 0.216-0.092l16.635-16.599c0.124-0.124 0.124-0.328 0-0.452l-4.972-4.968c-0.064-0.064-0.144-0.092-0.228-0.092s-0.164 0.032-0.228 0.092l-16.631 16.599c-0.056 0.058-0.091 0.137-0.092 0.224v0zM12.296 17.86l14.412-14.38 1.808 1.804-14.42 14.388-1.828 0.044 0.028-1.856z"></path>
              </symbol>
              <symbol id="vditor-icon-info" viewBox="0 0 32 32">
                <path d="M13.124 3.056c0 1.589 1.288 2.876 2.876 2.876s2.876-1.288 2.876-2.876v0c0-1.589-1.288-2.876-2.876-2.876s-2.876 1.288-2.876 2.876v0zM17.438 10.607h-2.876c-0.198 0-0.36 0.162-0.36 0.36v20.854c0 0.198 0.162 0.36 0.36 0.36h2.876c0.198 0 0.36-0.162 0.36-0.36v-20.854c0-0.198-0.162-0.36-0.36-0.36z"></path>
              </symbol>
              <symbol id="vditor-icon-help" viewBox="0 0 32 32">
                <path d="M26.419 6.445c-0.579-1.265-1.402-2.402-2.452-3.374-2.133-1.98-4.965-3.072-7.967-3.072s-5.834 1.091-7.967 3.068c-1.050 0.976-1.873 2.109-2.452 3.378-0.604 1.323-0.91 2.725-0.91 4.172v1.116c0 0.256 0.207 0.463 0.463 0.463h2.233c0.256 0 0.463-0.207 0.463-0.463v-1.116c0-4.114 3.663-7.458 8.169-7.458s8.169 3.345 8.169 7.458c0 1.687-0.599 3.274-1.736 4.597-1.125 1.311-2.712 2.249-4.469 2.646-1.005 0.227-1.91 0.794-2.551 1.604-0.615 0.772-0.987 1.76-0.988 2.836v1.299c0 0.256 0.207 0.463 0.463 0.463h2.233c0.256 0 0.463-0.207 0.463-0.463v-1.298c0-0.649 0.451-1.22 1.075-1.36 2.414-0.546 4.606-1.848 6.173-3.667 0.79-0.922 1.406-1.947 1.832-3.059 0.442-1.153 0.666-2.365 0.666-3.597 0-1.447-0.306-2.853-0.91-4.172zM16 27.369c-1.278 0-2.315 1.038-2.315 2.315s1.038 2.315 2.315 2.315 2.315-1.038 2.315-2.315-1.038-2.315-2.315-2.315z"></path>
              </symbol>
              <symbol id="vditor-icon-strike" viewBox="0 0 32 32">
                <path d="M31.714 14.643h-13.646c-0.357-0.071-0.732-0.143-1.129-0.214-0.568-0.104-0.793-0.146-1.1-0.207-1.832-0.357-2.936-0.714-3.814-1.221-1.254-0.732-1.864-1.725-1.864-3.039 0-1.321 0.543-2.418 1.571-3.179 1.014-0.75 2.457-1.146 4.171-1.146 1.957 0 3.468 0.514 4.493 1.529 0.521 0.514 0.904 1.146 1.136 1.879 0.046 0.146 0.1 0.357 0.154 0.636 0.032 0.171 0.186 0.293 0.354 0.293h2.6c0.2 0 0.361-0.164 0.361-0.361v-0.036c-0.025-0.243-0.046-0.432-0.071-0.571-0.261-1.554-1-2.918-2.132-3.939-1.586-1.446-3.918-2.207-6.739-2.207-2.582 0-4.907 0.646-6.546 1.818-0.914 0.657-1.621 1.471-2.093 2.418-0.482 0.968-0.725 2.086-0.725 3.318 0 1.054 0.204 1.946 0.618 2.732 0.296 0.561 0.7 1.054 1.218 1.5h-8.243c-0.157 0-0.286 0.129-0.286 0.286v2.143c0 0.157 0.129 0.286 0.286 0.286h15.471c0.075 0.014 0.139 0.029 0.211 0.043 1.104 0.221 1.768 0.371 2.379 0.543 0.821 0.232 1.45 0.475 1.971 0.768 1.279 0.721 1.904 1.757 1.904 3.179 0 1.261-0.554 2.386-1.557 3.171-1.089 0.854-2.7 1.3-4.661 1.3-1.561 0-2.882-0.304-3.936-0.893-1.039-0.582-1.754-1.421-2.132-2.482-0.029-0.079-0.061-0.186-0.096-0.321-0.043-0.157-0.189-0.268-0.346-0.268h-2.846c-0.2 0-0.361 0.164-0.361 0.361v0.036c0.007 0.082 0.014 0.15 0.021 0.204 0.232 1.743 1.082 3.171 2.525 4.243 1.682 1.243 4.050 1.9 6.85 1.9 3.007 0 5.529-0.707 7.293-2.046 0.893-0.675 1.579-1.507 2.039-2.464 0.464-0.968 0.704-2.068 0.704-3.268 0-1.136-0.207-2.086-0.636-2.907-0.207-0.4-0.468-0.768-0.779-1.1h7.411c0.157 0 0.286-0.129 0.286-0.286v-2.143c-0.002-0.156-0.129-0.282-0.286-0.282 0 0 0 0-0 0v0z"></path>
              </symbol>
              <symbol id="vditor-icon-contract" viewBox="0 0 32 32">
                <path d="M31.9 2.040l-1.94-1.94c-0.062-0.062-0.148-0.1-0.243-0.1s-0.181 0.038-0.243 0.1l-6.774 6.778-2.352-2.353c-0.062-0.062-0.147-0.1-0.241-0.1-0.175 0-0.319 0.131-0.339 0.3l-0 0.002-1.011 8.133c-0.026 0.224 0.159 0.409 0.383 0.383l8.137-1.011c0.284-0.034 0.4-0.378 0.202-0.581l-2.352-2.352 6.778-6.778c0.129-0.129 0.129-0.348-0.004-0.482zM12.86 18.757l-8.137 1.011c-0.284 0.034-0.4 0.383-0.202 0.581l2.353 2.352-6.774 6.774c-0.062 0.062-0.1 0.148-0.1 0.243s0.038 0.181 0.1 0.243l1.94 1.94c0.133 0.133 0.353 0.133 0.486 0l6.778-6.778 2.352 2.352c0.062 0.062 0.147 0.1 0.241 0.1 0.175 0 0.319-0.131 0.339-0.3l0-0.002 1.006-8.133c0.002-0.014 0.003-0.030 0.003-0.046 0-0.188-0.152-0.34-0.34-0.34-0.016 0-0.032 0.001-0.048 0.003l0.002-0z"></path>
              </symbol>
              <symbol id="vditor-icon-record" viewBox="0 0 32 32">
                <path d="M27.786 13.929c0-0.157-0.129-0.286-0.286-0.286h-2.143c-0.157 0-0.286 0.129-0.286 0.286 0 5.011-4.061 9.071-9.071 9.071s-9.071-4.061-9.071-9.071c0-0.157-0.129-0.286-0.286-0.286h-2.143c-0.157 0-0.286 0.129-0.286 0.286 0 6.025 4.521 10.996 10.357 11.7v3.657h-5.189c-0.489 0-0.882 0.511-0.882 1.143v1.286c0 0.157 0.1 0.286 0.221 0.286h14.557c0.121 0 0.221-0.129 0.221-0.286v-1.286c0-0.632-0.393-1.143-0.882-1.143h-5.332v-3.639c5.904-0.643 10.5-5.643 10.5-11.718zM16 20c3.354 0 6.071-2.686 6.071-6v-8c0-3.314-2.718-6-6.071-6s-6.071 2.686-6.071 6v8c0 3.314 2.718 6 6.071 6zM12.643 6c0-1.807 1.496-3.286 3.357-3.286s3.357 1.479 3.357 3.286v8c0 1.807-1.496 3.286-3.357 3.286s-3.357-1.479-3.357-3.286v-8z"></path>
              </symbol>
              <symbol id="vditor-icon-bold" viewBox="0 0 32 32">
                <path d="M24.078 14.67c1.461-1.522 2.357-3.578 2.357-5.839v-0.443c0-4.678-3.83-8.474-8.552-8.474h-12.865c-0.657 0-1.191 0.535-1.191 1.191v29.526c0 0.709 0.574 1.283 1.283 1.283h13.857c5.087 0 9.209-4.096 9.209-9.152v-0.478c0-3.174-1.626-5.97-4.096-7.613zM8 4.087h9.77c2.483 0 4.491 1.93 4.491 4.317v0.413c0 2.383-2.013 4.317-4.491 4.317h-9.77v-9.048zM23.939 22.757c0 2.735-2.248 4.952-5.022 4.952h-10.917v-10.374h10.917c2.774 0 5.022 2.217 5.022 4.952v0.47z"></path>
              </symbol>
              <symbol id="vditor-icon-bug" viewBox="0 0 32 32">
                <path d="M8.571 7.714h2c0.157 0 0.286-0.129 0.286-0.286 0-1.011 0.211-1.9 0.611-2.625 0.379-0.693 0.929-1.243 1.621-1.621 0.729-0.396 1.614-0.611 2.625-0.611h0.571c1.011 0 1.9 0.211 2.625 0.611 0.693 0.379 1.243 0.929 1.621 1.621 0.396 0.729 0.611 1.614 0.611 2.625 0 0.157 0.129 0.286 0.286 0.286h2c0.157 0 0.286-0.129 0.286-0.286 0-1.429-0.314-2.739-0.925-3.861-0.614-1.125-1.518-2.029-2.643-2.643-1.121-0.611-2.432-0.925-3.861-0.925h-0.571c-1.429 0-2.739 0.314-3.861 0.925-1.125 0.614-2.029 1.518-2.643 2.643-0.611 1.121-0.925 2.432-0.925 3.861 0 0.157 0.129 0.286 0.286 0.286z"></path>
                <path d="M31.286 16h-5.286v-3.571c2.743 0 4.964-2.221 4.964-4.964 0-0.157-0.129-0.286-0.286-0.286h-2.143c-0.157 0-0.286 0.129-0.286 0.286 0 1.243-1.007 2.25-2.25 2.25h-20c-1.243 0-2.25-1.007-2.25-2.25 0-0.157-0.129-0.286-0.286-0.286h-2.143c-0.157 0-0.286 0.129-0.286 0.286 0 2.743 2.221 4.964 4.964 4.964v3.571h-5.286c-0.157 0-0.286 0.129-0.286 0.286v2c0 0.157 0.129 0.286 0.286 0.286h5.286v3.429c0 0.232 0.007 0.464 0.025 0.689-2.45 1.046-4.168 3.479-4.168 6.311 0 0.157 0.129 0.286 0.286 0.286h2c0.157 0 0.286-0.129 0.286-0.286 0-1.579 0.854-2.961 2.129-3.704 0.214 0.614 0.486 1.2 0.811 1.75 0.868 1.482 2.107 2.721 3.589 3.589s3.204 1.364 5.043 1.364 3.564-0.496 5.046-1.364c1.482-0.868 2.721-2.107 3.589-3.589 0.325-0.554 0.596-1.139 0.811-1.75 1.271 0.743 2.125 2.125 2.125 3.704 0 0.157 0.129 0.286 0.286 0.286h2c0.157 0 0.286-0.129 0.286-0.286 0-2.832-1.718-5.264-4.168-6.311 0.014-0.229 0.025-0.457 0.025-0.689v-3.429h5.286c0.157 0 0.286-0.129 0.286-0.286v-2c0-0.157-0.129-0.286-0.286-0.286zM23.286 22c0 1.314-0.346 2.571-0.993 3.675-0.632 1.082-1.536 1.986-2.618 2.618-1.104 0.646-2.361 0.993-3.675 0.993s-2.571-0.346-3.675-0.993c-1.082-0.632-1.986-1.536-2.618-2.618-0.646-1.104-0.993-2.361-0.993-3.675v-9.571h14.571v9.571z"></path>
              </symbol>
              <symbol id="vditor-icon-play" viewBox="0 0 32 32">
                <path d="M25.263 15.159l-17.308-14.927c-0.645-0.555-1.591-0.055-1.591 0.841v29.853c0 0.895 0.945 1.395 1.591 0.841l17.308-14.927c0.495-0.427 0.495-1.255 0-1.682z"></path>
              </symbol>
              <symbol id="vditor-icon-check" viewBox="0 0 32 32">
                <path d="M12.844 21.828c0.234 0.323 0.61 0.531 1.034 0.531s0.8-0.208 1.031-0.527l0.003-0.004 8.424-11.68c0.152-0.212 0-0.508-0.26-0.508h-1.876c-0.408 0-0.796 0.196-1.036 0.532l-6.284 8.72-2.848-3.952c-0.24-0.332-0.624-0.532-1.036-0.532h-1.876c-0.26 0-0.412 0.296-0.26 0.508l4.984 6.912z"></path>
                <path d="M30.72 0h-29.44c-0.708 0-1.28 0.572-1.28 1.28v29.44c0 0.708 0.572 1.28 1.28 1.28h29.44c0.708 0 1.28-0.572 1.28-1.28v-29.44c0-0.708-0.572-1.28-1.28-1.28zM29.12 29.12h-26.24v-26.24h26.24v26.24z"></path>
              </symbol>
              <symbol id="vditor-icon-upload" viewBox="0 0 32 32">
                <path d="M16.225 14.107c-0.053-0.067-0.134-0.11-0.225-0.11s-0.172 0.043-0.225 0.109l-0 0.001-4 5.061c-0.038 0.048-0.061 0.109-0.061 0.176 0 0.157 0.128 0.285 0.285 0.285 0 0 0 0 0.001 0h2.639v8.657c0 0.157 0.129 0.286 0.286 0.286h2.143c0.157 0 0.286-0.129 0.286-0.286v-8.654h2.646c0.239 0 0.371-0.275 0.225-0.461l-4-5.064z"></path>
                <path d="M26.693 10.811c-1.636-4.314-5.804-7.382-10.686-7.382s-9.050 3.064-10.686 7.379c-3.061 0.804-5.321 3.593-5.321 6.907 0 3.946 3.196 7.143 7.139 7.143h1.432c0.157 0 0.286-0.129 0.286-0.286v-2.143c0-0.157-0.129-0.286-0.286-0.286h-1.432c-1.204 0-2.336-0.479-3.179-1.346-0.839-0.864-1.286-2.029-1.246-3.236 0.032-0.943 0.354-1.829 0.936-2.575 0.596-0.761 1.432-1.314 2.361-1.561l1.354-0.354 0.496-1.307c0.307-0.814 0.736-1.575 1.275-2.264 0.537-0.685 1.154-1.273 1.844-1.764l0.027-0.018c1.468-1.032 3.196-1.579 5-1.579s3.532 0.546 5 1.579c0.711 0.5 1.339 1.1 1.871 1.782 0.539 0.689 0.968 1.454 1.275 2.264l0.493 1.304 1.35 0.357c1.936 0.521 3.289 2.282 3.289 4.289 0 1.182-0.461 2.296-1.296 3.132-0.796 0.801-1.899 1.296-3.117 1.296-0.004 0-0.008 0-0.012 0h-1.431c-0.157 0-0.286 0.129-0.286 0.286v2.143c0 0.157 0.129 0.286 0.286 0.286h1.432c3.943 0 7.139-3.196 7.139-7.143 0-3.311-2.254-6.096-5.307-6.904z"></path>
              </symbol>
              <symbol id="vditor-icon-trashcan" viewBox="0 0 32 32">
                <path d="M9.92 2.88h-0.32c0.176 0 0.32-0.144 0.32-0.32v0.32h12.16v-0.32c0 0.176 0.144 0.32 0.32 0.32h-0.32v2.88h2.88v-3.2c0-1.412-1.148-2.56-2.56-2.56h-12.8c-1.412 0-2.56 1.148-2.56 2.56v3.2h2.88v-2.88zM30.080 5.76h-28.16c-0.708 0-1.28 0.572-1.28 1.28v1.28c0 0.176 0.144 0.32 0.32 0.32h2.416l0.988 20.92c0.064 1.364 1.192 2.44 2.556 2.44h18.16c1.368 0 2.492-1.072 2.556-2.44l0.988-20.92h2.416c0.176 0 0.32-0.144 0.32-0.32v-1.28c0-0.708-0.572-1.28-1.28-1.28zM24.772 29.12h-17.544l-0.968-20.48h19.48l-0.968 20.48z"></path>
              </symbol>
              <symbol id="vditor-icon-more" viewBox="0 0 32 32">
                <path d="M0 15.952c0 1.473 1.194 2.667 2.667 2.667s2.667-1.194 2.667-2.667v0c0-1.473-1.194-2.667-2.667-2.667s-2.667 1.194-2.667 2.667v0zM13.333 15.952c0 1.473 1.194 2.667 2.667 2.667s2.667-1.194 2.667-2.667v0c0-1.473-1.194-2.667-2.667-2.667s-2.667 1.194-2.667 2.667v0zM26.667 15.952c0 1.473 1.194 2.667 2.667 2.667s2.667-1.194 2.667-2.667v0c0-1.473-1.194-2.667-2.667-2.667s-2.667 1.194-2.667 2.667v0z"></path>
              </symbol>
              <symbol id="vditor-icon-fullscreen" viewBox="0 0 32 32">
                <path d="M31.592 0.003l-8.601 1.068c-0.3 0.036-0.423 0.4-0.214 0.614l2.487 2.487-6.978 6.978c-0.065 0.066-0.106 0.157-0.106 0.257s0.040 0.191 0.106 0.257l2.050 2.050c0.141 0.141 0.373 0.141 0.514 0l6.983-6.983 2.487 2.487c0.065 0.065 0.155 0.106 0.255 0.106 0.185 0 0.337-0.139 0.358-0.318l0-0.002 1.064-8.596c0.002-0.015 0.003-0.032 0.003-0.049 0-0.198-0.161-0.359-0.359-0.359-0.017 0-0.034 0.001-0.051 0.004l0.002-0zM11.663 18.287c-0.066-0.065-0.157-0.106-0.257-0.106s-0.191 0.040-0.257 0.106l-6.978 6.982-2.487-2.487c-0.065-0.065-0.155-0.106-0.255-0.106-0.185 0-0.337 0.139-0.358 0.318l-0 0.002-1.068 8.596c-0.027 0.236 0.168 0.432 0.405 0.405l8.601-1.068c0.3-0.036 0.423-0.4 0.214-0.614l-2.487-2.487 6.983-6.983c0.141-0.141 0.141-0.373 0-0.514l-2.055-2.046z"></path>
              </symbol>
              <symbol id="vditor-icon-emoji" viewBox="0 0 32 32">
                <path d="M8 12.75c0 0.947 0.768 1.714 1.714 1.714s1.714-0.768 1.714-1.714v0c0-0.947-0.768-1.714-1.714-1.714s-1.714 0.768-1.714 1.714v0zM20.571 12.75c0 0.947 0.767 1.714 1.714 1.714s1.714-0.768 1.714-1.714v0c0-0.947-0.767-1.714-1.714-1.714s-1.714 0.768-1.714 1.714v0zM16 0c-8.836 0-16 7.164-16 16s7.164 16 16 16 16-7.164 16-16-7.164-16-16-16zM25.393 25.393c-1.221 1.221-2.643 2.179-4.225 2.85-1.632 0.693-3.371 1.043-5.168 1.043s-3.536-0.35-5.171-1.043c-1.643-0.704-3.045-1.666-4.225-2.85l-0-0c-1.221-1.221-2.179-2.643-2.85-4.225-0.689-1.632-1.039-3.371-1.039-5.168s0.35-3.536 1.043-5.171c0.704-1.643 1.666-3.045 2.85-4.225l0-0c1.221-1.221 2.643-2.179 4.225-2.85 1.632-0.689 3.371-1.039 5.168-1.039s3.536 0.35 5.171 1.043c1.643 0.704 3.045 1.666 4.225 2.85l0 0c1.221 1.221 2.179 2.643 2.85 4.225 0.689 1.632 1.039 3.371 1.039 5.168s-0.35 3.536-1.043 5.171c-0.703 1.642-1.665 3.043-2.849 4.221l-0.001 0.001zM21.429 16.75h-1.718c-0.15 0-0.279 0.114-0.289 0.264-0.136 1.768-1.618 3.164-3.421 3.164s-3.289-1.396-3.421-3.164c-0.011-0.15-0.139-0.264-0.289-0.264h-1.718c-0 0-0 0-0 0-0.158 0-0.286 0.128-0.286 0.286 0 0.005 0 0.010 0 0.015l-0-0.001c0.157 3.011 2.661 5.414 5.714 5.414s5.557-2.404 5.714-5.414c0-0.004 0-0.009 0-0.014 0-0.158-0.128-0.286-0.286-0.286-0 0-0 0-0 0h0z"></path>
              </symbol>
              <symbol id="vditor-icon-align-center" viewBox="0 0 32 32">
                <path d="M6.080 4.72h19.84c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32h-19.84c-0.176 0-0.32 0.144-0.32 0.32v2.24c0 0.176 0.144 0.32 0.32 0.32zM25.92 21.68c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32h-19.84c-0.176 0-0.32 0.144-0.32 0.32v2.24c0 0.176 0.144 0.32 0.32 0.32h19.84zM31.68 27.28h-31.36c-0.176 0-0.32 0.144-0.32 0.32v2.24c0 0.176 0.144 0.32 0.32 0.32h31.36c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32zM31.68 10.32h-31.36c-0.176 0-0.32 0.144-0.32 0.32v2.24c0 0.176 0.144 0.32 0.32 0.32h31.36c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32z"></path>
              </symbol>
              <symbol id="vditor-icon-align-left" viewBox="0 0 32 32">
                <path d="M0.32 4.72h19.84c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32h-19.84c-0.176 0-0.32 0.144-0.32 0.32v2.24c0 0.176 0.144 0.32 0.32 0.32zM0.32 21.68h19.84c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32h-19.84c-0.176 0-0.32 0.144-0.32 0.32v2.24c0 0.176 0.144 0.32 0.32 0.32zM31.68 27.28h-31.36c-0.176 0-0.32 0.144-0.32 0.32v2.24c0 0.176 0.144 0.32 0.32 0.32h31.36c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32zM31.68 10.32h-31.36c-0.176 0-0.32 0.144-0.32 0.32v2.24c0 0.176 0.144 0.32 0.32 0.32h31.36c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32z"></path>
              </symbol>
              <symbol id="vditor-icon-align-right" viewBox="0 0 32 32">
                <path d="M31.68 1.84h-19.84c-0.176 0-0.32 0.144-0.32 0.32v2.24c0 0.176 0.144 0.32 0.32 0.32h19.84c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32zM31.68 18.8h-19.84c-0.176 0-0.32 0.144-0.32 0.32v2.24c0 0.176 0.144 0.32 0.32 0.32h19.84c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32zM31.68 27.28h-31.36c-0.176 0-0.32 0.144-0.32 0.32v2.24c0 0.176 0.144 0.32 0.32 0.32h31.36c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32zM31.68 10.32h-31.36c-0.176 0-0.32 0.144-0.32 0.32v2.24c0 0.176 0.144 0.32 0.32 0.32h31.36c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32z"></path>
              </symbol>
              <symbol id="vditor-icon-delete-column" viewBox="0 0 32 32">
                <path d="M21.563 21.195c-0.056-0.048-0.128-0.076-0.204-0.076h-2.188c-0.096 0-0.184 0.044-0.244 0.116l-2.928 3.512-2.924-3.512c-0.060-0.072-0.152-0.116-0.244-0.116h-2.192c-0.076 0-0.148 0.028-0.204 0.076-0.136 0.112-0.156 0.316-0.040 0.452l4.091 4.911-4.096 4.915c-0.112 0.136-0.096 0.336 0.040 0.452 0.056 0.048 0.128 0.076 0.204 0.076h2.188c0.096 0 0.184-0.044 0.244-0.116l2.924-3.512 2.924 3.512c0.060 0.072 0.152 0.116 0.244 0.116h2.2c0.076 0 0.148-0.028 0.204-0.076 0.136-0.112 0.156-0.316 0.040-0.452l-4.091-4.915 4.096-4.915c0.112-0.136 0.092-0.336-0.044-0.448zM14.4 17.28h3.2c0.176 0 0.32-0.144 0.32-0.32v-16.638c0-0.176-0.144-0.32-0.32-0.32h-3.2c-0.176 0-0.32 0.144-0.32 0.32v16.638c0 0.176 0.144 0.32 0.32 0.32zM9.521 10.961h-6.639v-9.999c0-0.132-0.108-0.24-0.24-0.24h-2.4c-0.132 0-0.24 0.108-0.24 0.24v11.679c0 0.664 0.536 1.2 1.2 1.2h8.319c0.132 0 0.24-0.108 0.24-0.24v-2.4c0-0.132-0.108-0.24-0.24-0.24zM31.758 0.722h-2.4c-0.132 0-0.24 0.108-0.24 0.24v9.999h-6.639c-0.132 0-0.24 0.108-0.24 0.24v2.4c0 0.132 0.108 0.24 0.24 0.24h8.319c0.664 0 1.2-0.536 1.2-1.2v-11.679c0-0.132-0.108-0.24-0.24-0.24z"></path>
              </symbol>
              <symbol id="vditor-icon-delete-row" viewBox="0 0 32 32">
                <path d="M28.129 16l4.035-4.843c0.11-0.134 0.095-0.331-0.039-0.445-0.055-0.047-0.126-0.075-0.201-0.075h-2.156c-0.095 0-0.181 0.043-0.24 0.114l-2.888 3.464-2.881-3.46c-0.059-0.071-0.15-0.114-0.24-0.114h-2.159c-0.075 0-0.146 0.028-0.201 0.075-0.134 0.11-0.154 0.311-0.039 0.445l4.031 4.839-4.035 4.843c-0.11 0.134-0.095 0.331 0.039 0.445 0.055 0.047 0.126 0.075 0.201 0.075h2.156c0.095 0 0.181-0.043 0.24-0.114l2.881-3.46 2.881 3.46c0.059 0.071 0.15 0.114 0.24 0.114h2.167c0.075 0 0.146-0.028 0.201-0.075 0.134-0.11 0.154-0.311 0.039-0.445l-4.031-4.843zM16.946 14.108h-16.393c-0.173 0-0.315 0.142-0.315 0.315v3.153c0 0.173 0.142 0.315 0.315 0.315h16.393c0.173 0 0.315-0.142 0.315-0.315v-3.152c0-0.173-0.142-0.315-0.315-0.315zM13.636 22.147h-2.364c-0.13 0-0.236 0.106-0.236 0.236v6.541h-9.852c-0.13 0-0.236 0.106-0.236 0.236v2.364c0 0.13 0.106 0.236 0.236 0.236h11.507c0.654 0 1.182-0.528 1.182-1.182v-8.197c0-0.13-0.106-0.236-0.236-0.236zM1.183 3.075h9.852v6.541c0 0.13 0.106 0.236 0.236 0.236h2.364c0.13 0 0.236-0.106 0.236-0.236v-8.197c0-0.654-0.528-1.182-1.182-1.182h-11.507c-0.13 0-0.236 0.106-0.236 0.236v2.364c0 0.13 0.106 0.236 0.236 0.236z"></path>
              </symbol>
              <symbol id="vditor-icon-down" viewBox="0 0 32 32">
                <path d="M31.663 5.221h-3.158c-0.215 0-0.417 0.105-0.543 0.278l-11.962 16.489-11.962-16.489c-0.126-0.173-0.328-0.278-0.543-0.278h-3.158c-0.274 0-0.434 0.312-0.274 0.535l14.847 20.468c0.539 0.741 1.642 0.741 2.177 0l14.847-20.468c0.164-0.223 0.004-0.535-0.269-0.535z"></path>
              </symbol>
              <symbol id="vditor-icon-insert-row" viewBox="0 0 32 32">
                <path d="M30.668 23.040h-29.336c-0.736 0-1.332-0.572-1.332-1.28v-18.56c0-0.708 0.596-1.28 1.332-1.28h29.332c0.736 0 1.332 0.572 1.332 1.28v18.56c0.004 0.708-0.592 1.28-1.328 1.28zM9.92 4.8h-7.040v6.4h7.040v-6.4zM9.92 13.76h-7.040v6.4h7.040v-6.4zM19.52 4.8h-7.040v6.4h7.040v-6.4zM19.52 13.76h-7.040v6.4h7.040v-6.4zM29.12 4.8h-7.040v6.4h7.040v-6.4zM29.12 13.76h-7.040v6.4h7.040v-6.4zM31.68 30.080h-31.36c-0.176 0-0.32-0.144-0.32-0.32v-3.2c0-0.176 0.144-0.32 0.32-0.32h31.36c0.176 0 0.32 0.144 0.32 0.32v3.2c0 0.176-0.144 0.32-0.32 0.32z"></path>
              </symbol>
              <symbol id="vditor-icon-insert-rowb" viewBox="0 0 32 32">
                <path d="M30.668 8.96h-29.336c-0.736 0-1.332 0.572-1.332 1.28v18.56c0 0.708 0.596 1.28 1.332 1.28h29.332c0.736 0 1.332-0.572 1.332-1.28v-18.56c0.004-0.708-0.592-1.28-1.328-1.28zM9.92 27.2h-7.040v-6.4h7.040v6.4zM9.92 18.24h-7.040v-6.4h7.040v6.4zM19.52 27.2h-7.040v-6.4h7.040v6.4zM19.52 18.24h-7.040v-6.4h7.040v6.4zM29.12 27.2h-7.040v-6.4h7.040v6.4zM29.12 18.24h-7.040v-6.4h7.040v6.4zM31.68 1.92h-31.36c-0.176 0-0.32 0.144-0.32 0.32v3.2c0 0.176 0.144 0.32 0.32 0.32h31.36c0.176 0 0.32-0.144 0.32-0.32v-3.2c0-0.176-0.144-0.32-0.32-0.32z"></path>
              </symbol>
              <symbol id="vditor-icon-insert-column" viewBox="0 0 32 32">
                <path d="M29.76 0h-3.2c-0.176 0-0.32 0.144-0.32 0.32v31.36c0 0.176 0.144 0.32 0.32 0.32h3.2c0.176 0 0.32-0.144 0.32-0.32v-31.36c0-0.176-0.144-0.32-0.32-0.32zM21.76 0h-18.56c-0.708 0-1.28 0.596-1.28 1.332v29.332c0 0.736 0.572 1.332 1.28 1.332h18.56c0.708 0 1.28-0.596 1.28-1.332v-29.332c0-0.736-0.572-1.332-1.28-1.332zM11.2 29.12h-6.4v-7.040h6.4v7.040zM11.2 19.52h-6.4v-7.040h6.4v7.040zM11.2 9.92h-6.4v-7.040h6.4v7.040zM20.16 29.12h-6.4v-7.040h6.4v7.040zM20.16 19.52h-6.4v-7.040h6.4v7.040zM20.16 9.92h-6.4v-7.040h6.4v7.040z"></path>
              </symbol>
              <symbol id="vditor-icon-insert-columnb" viewBox="0 0 32 32">
                <path d="M2.24 32h3.2c0.176 0 0.32-0.144 0.32-0.32v-31.36c0-0.176-0.144-0.32-0.32-0.32h-3.2c-0.176 0-0.32 0.144-0.32 0.32v31.36c0 0.176 0.144 0.32 0.32 0.32zM10.24 32h18.56c0.708 0 1.28-0.596 1.28-1.332v-29.332c0-0.736-0.572-1.332-1.28-1.332h-18.56c-0.708 0-1.28 0.596-1.28 1.332v29.332c0 0.736 0.572 1.332 1.28 1.332zM20.8 2.88h6.4v7.040h-6.4v-7.040zM20.8 12.48h6.4v7.040h-6.4v-7.040zM20.8 22.080h6.4v7.040h-6.4v-7.040zM11.84 2.88h6.4v7.040h-6.4v-7.040zM11.84 12.48h6.4v7.040h-6.4v-7.040zM11.84 22.080h6.4v7.040h-6.4v-7.040z"></path>
              </symbol>
              <symbol id="vditor-icon-italic" viewBox="0 0 32 32">
                <path d="M29 0h-19.636c-0.2 0-0.364 0.164-0.364 0.364v2.909c0 0.2 0.164 0.364 0.364 0.364h8.236l-7.091 24.727h-7.373c-0.2 0-0.364 0.164-0.364 0.364v2.909c0 0.2 0.164 0.364 0.364 0.364h19.636c0.2 0 0.364-0.164 0.364-0.364v-2.909c0-0.2-0.164-0.364-0.364-0.364h-8.482l7.091-24.727h7.618c0.2 0 0.364-0.164 0.364-0.364v-2.909c0-0.2-0.164-0.364-0.364-0.364z"></path>
              </symbol>
              <symbol id="vditor-icon-link" viewBox="0 0 32 32">
                <path d="M18.583 22.391c-0.060-0.060-0.144-0.097-0.235-0.097s-0.175 0.037-0.235 0.097l-4.841 4.841c-2.242 2.242-6.025 2.479-8.5 0-2.479-2.479-2.242-6.258 0-8.5l4.841-4.841c0.129-0.129 0.129-0.342 0-0.471l-1.658-1.658c-0.060-0.060-0.144-0.097-0.235-0.097s-0.175 0.037-0.235 0.097l-4.841 4.841c-3.525 3.525-3.525 9.229 0 12.75s9.229 3.525 12.75 0l4.841-4.841c0.129-0.129 0.129-0.342 0-0.471l-1.65-1.65zM29.358 2.642c-3.525-3.525-9.229-3.525-12.75 0l-4.846 4.841c-0.060 0.060-0.097 0.144-0.097 0.235s0.037 0.175 0.097 0.235l1.654 1.654c0.129 0.129 0.342 0.129 0.471 0l4.842-4.841c2.242-2.242 6.025-2.479 8.5 0 2.479 2.479 2.242 6.258 0 8.5l-4.841 4.841c-0.060 0.060-0.097 0.144-0.097 0.235s0.037 0.175 0.097 0.235l1.658 1.658c0.129 0.129 0.342 0.129 0.471 0l4.841-4.841c3.521-3.525 3.521-9.229 0-12.754zM20.087 10.179c-0.060-0.060-0.144-0.097-0.235-0.097s-0.175 0.037-0.235 0.097l-9.437 9.433c-0.060 0.060-0.097 0.144-0.097 0.235s0.037 0.175 0.097 0.235l1.65 1.65c0.129 0.129 0.342 0.129 0.471 0l9.433-9.433c0.129-0.129 0.129-0.342 0-0.471l-1.646-1.65z"></path>
              </symbol>
              <symbol id="vditor-icon-outdent" viewBox="0 0 32 32">
                <path d="M11.84 13.2h19.2c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32h-19.2c-0.176 0-0.32 0.144-0.32 0.32v2.24c0 0.176 0.144 0.32 0.32 0.32zM11.52 21.36c0 0.176 0.144 0.32 0.32 0.32h19.2c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32h-19.2c-0.176 0-0.32 0.144-0.32 0.32v2.24zM31.68 1.92h-31.36c-0.176 0-0.32 0.144-0.32 0.32v2.24c0 0.176 0.144 0.32 0.32 0.32h31.36c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32zM31.68 27.2h-31.36c-0.176 0-0.32 0.144-0.32 0.32v2.24c0 0.176 0.144 0.32 0.32 0.32h31.36c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32zM0.136 16.276l6.252 4.924c0.232 0.184 0.576 0.020 0.576-0.276v-9.848c0-0.296-0.34-0.46-0.576-0.276l-6.252 4.924c-0.082 0.065-0.135 0.164-0.135 0.276s0.053 0.211 0.134 0.275l0.001 0.001z"></path>
              </symbol>
              <symbol id="vditor-icon-indent" viewBox="0 0 32 32">
                <path d="M11.84 13.2h19.2c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32h-19.2c-0.176 0-0.32 0.144-0.32 0.32v2.24c0 0.176 0.144 0.32 0.32 0.32zM11.52 21.36c0 0.176 0.144 0.32 0.32 0.32h19.2c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32h-19.2c-0.176 0-0.32 0.144-0.32 0.32v2.24zM31.68 1.92h-31.36c-0.176 0-0.32 0.144-0.32 0.32v2.24c0 0.176 0.144 0.32 0.32 0.32h31.36c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32zM31.68 27.2h-31.36c-0.176 0-0.32 0.144-0.32 0.32v2.24c0 0.176 0.144 0.32 0.32 0.32h31.36c0.176 0 0.32-0.144 0.32-0.32v-2.24c0-0.176-0.144-0.32-0.32-0.32zM1.216 21.204l6.252-4.924c0.083-0.065 0.135-0.166 0.135-0.278s-0.053-0.213-0.134-0.277l-0.001-0.001-6.252-4.928c-0.232-0.184-0.576-0.020-0.576 0.276v9.852c0 0 0 0 0 0 0 0.197 0.159 0.356 0.356 0.356 0.083 0 0.16-0.029 0.221-0.077l-0.001 0.001z"></path>
              </symbol>
              <symbol id="vditor-icon-ordered-list" viewBox="0 0 32 32">
                <path d="M31.692 25.538h-22.462c-0.169 0-0.308 0.138-0.308 0.308v2.154c0 0.169 0.138 0.308 0.308 0.308h22.462c0.169 0 0.308-0.138 0.308-0.308v-2.154c0-0.169-0.138-0.308-0.308-0.308zM31.692 3.692h-22.462c-0.169 0-0.308 0.138-0.308 0.308v2.154c0 0.169 0.138 0.308 0.308 0.308h22.462c0.169 0 0.308-0.138 0.308-0.308v-2.154c0-0.169-0.138-0.308-0.308-0.308zM31.692 14.615h-22.462c-0.169 0-0.308 0.138-0.308 0.308v2.154c0 0.169 0.138 0.308 0.308 0.308h22.462c0.169 0 0.308-0.138 0.308-0.308v-2.154c0-0.169-0.138-0.308-0.308-0.308zM4.615 23.692h-4.462c-0.085 0-0.154 0.069-0.154 0.154v1.308c0 0.085 0.069 0.154 0.154 0.154h2.785v0.788h-1.373c-0.085 0-0.154 0.069-0.154 0.154v1.308c0 0.085 0.069 0.154 0.154 0.154h1.373v0.827h-2.785c-0.085 0-0.154 0.069-0.154 0.154v1.308c0 0.085 0.069 0.154 0.154 0.154h4.462c0.085 0 0.154-0.069 0.154-0.154v-6.154c0-0.085-0.069-0.154-0.154-0.154zM0.154 3.538h1.462v4.615c0 0.085 0.069 0.154 0.154 0.154h1.538c0.085 0 0.154-0.069 0.154-0.154v-6c0-0.169-0.138-0.308-0.308-0.308h-3c-0.085 0-0.154 0.069-0.154 0.154v1.385c0 0.085 0.069 0.154 0.154 0.154zM4.615 12.769h-4.462c-0.085 0-0.154 0.069-0.154 0.154v1.385c0 0.085 0.069 0.154 0.154 0.154h2.631l-2.704 2.988c-0.049 0.055-0.080 0.128-0.081 0.207v1.419c0 0.085 0.069 0.154 0.154 0.154h4.462c0.085 0 0.154-0.069 0.154-0.154v-1.385c0-0.085-0.069-0.154-0.154-0.154h-2.631l2.704-2.988c0.049-0.055 0.080-0.128 0.081-0.207v-1.419c0-0.085-0.069-0.154-0.154-0.154z"></path>
              </symbol>
              <symbol id="vditor-icon-redo" viewBox="0 0 32 32">
                <path d="M25.848 29.084c3.744-2.928 6.152-7.488 6.152-12.608 0-8.836-7.14-15.984-15.976-15.996-8.848-0.012-16.024 7.152-16.024 15.996 0 5.008 2.3 9.476 5.904 12.408 0.14 0.112 0.344 0.088 0.456-0.052l1.576-2.020c0.108-0.136 0.084-0.332-0.048-0.444-0.324-0.264-0.636-0.548-0.936-0.848-1.14-1.136-2.066-2.486-2.712-3.985l-0.032-0.083c-0.672-1.572-1.008-3.248-1.008-4.976s0.336-3.404 1.004-4.98c0.644-1.524 1.568-2.892 2.744-4.068s2.544-2.1 4.068-2.744c1.58-0.668 3.256-1.004 4.984-1.004s3.404 0.336 4.98 1.004c1.524 0.644 2.892 1.568 4.068 2.744s2.1 2.544 2.744 4.068c0.668 1.576 1.004 3.252 1.004 4.98s-0.336 3.404-1.004 4.98c-0.678 1.582-1.604 2.932-2.744 4.068l-0 0c-0.372 0.372-0.764 0.72-1.172 1.040l-1.628-2.084c-0.059-0.076-0.15-0.124-0.253-0.124-0.15 0-0.276 0.103-0.31 0.242l-0 0.002-1.584 6.488c-0.048 0.2 0.104 0.396 0.308 0.396l6.68 0.032c0.268 0 0.42-0.308 0.252-0.516l-1.492-1.916z"></path>
              </symbol>
              <symbol id="vditor-icon-table" viewBox="0 0 32 32">
                <path d="M30.857 3.429h-29.714c-0.632 0-1.143 0.511-1.143 1.143v22.857c0 0.632 0.511 1.143 1.143 1.143h29.714c0.632 0 1.143-0.511 1.143-1.143v-22.857c0-0.632-0.511-1.143-1.143-1.143zM29.429 10.857h-7.571v-4.857h7.571v4.857zM29.429 18.857h-7.571v-5.714h7.571v5.714zM12.429 13.143h7.143v5.714h-7.143v-5.714zM19.571 10.857h-7.143v-4.857h7.143v4.857zM2.571 13.143h7.571v5.714h-7.571v-5.714zM2.571 6h7.571v4.857h-7.571v-4.857zM2.571 21.143h7.571v4.857h-7.571v-4.857zM12.429 21.143h7.143v4.857h-7.143v-4.857zM29.429 26h-7.571v-4.857h7.571v4.857z"></path>
              </symbol>
              <symbol id="vditor-icon-undo" viewBox="0 0 32 32">
                <path d="M15.976 0.48c-8.836 0.012-15.976 7.16-15.976 15.996 0 5.12 2.408 9.68 6.152 12.608l-1.5 1.92c-0.164 0.212-0.012 0.52 0.252 0.516l6.68-0.032c0.208 0 0.36-0.196 0.308-0.396l-1.58-6.492c-0.035-0.141-0.161-0.244-0.311-0.244-0.103 0-0.194 0.048-0.253 0.123l-0.001 0.001-1.628 2.084c-0.408-0.32-0.8-0.668-1.172-1.040-1.14-1.136-2.066-2.486-2.712-3.985l-0.032-0.083c-0.668-1.576-1.004-3.252-1.004-4.98s0.336-3.404 1.004-4.98c0.644-1.524 1.568-2.892 2.744-4.068s2.544-2.1 4.068-2.744c1.58-0.668 3.256-1.004 4.984-1.004s3.404 0.336 4.98 1.004c1.524 0.644 2.892 1.568 4.068 2.744s2.1 2.544 2.744 4.068c0.668 1.576 1.004 3.252 1.004 4.98s-0.336 3.404-1.004 4.98c-0.678 1.582-1.604 2.932-2.744 4.068l-0 0c-0.3 0.3-0.612 0.58-0.936 0.848-0.072 0.059-0.117 0.147-0.117 0.246 0 0.075 0.026 0.144 0.070 0.198l-0-0.001 1.576 2.020c0.112 0.14 0.316 0.164 0.456 0.052 3.604-2.936 5.904-7.404 5.904-12.412 0-8.844-7.176-16.008-16.024-15.996z"></path>
              </symbol>
              <symbol id="vditor-icon-list" viewBox="0 0 32 32">
                <path d="M31.686 3.451h-22.902c-0.173 0-0.314 0.141-0.314 0.314v2.196c0 0.173 0.141 0.314 0.314 0.314h22.902c0.173 0 0.314-0.141 0.314-0.314v-2.196c0-0.173-0.141-0.314-0.314-0.314zM31.686 14.588h-22.902c-0.173 0-0.314 0.141-0.314 0.314v2.196c0 0.173 0.141 0.314 0.314 0.314h22.902c0.173 0 0.314-0.141 0.314-0.314v-2.196c0-0.173-0.141-0.314-0.314-0.314zM31.686 25.726h-22.902c-0.173 0-0.314 0.141-0.314 0.314v2.196c0 0.173 0.141 0.314 0.314 0.314h22.902c0.173 0 0.314-0.141 0.314-0.314v-2.196c0-0.173-0.141-0.314-0.314-0.314zM0 4.863c0 1.213 0.983 2.196 2.196 2.196s2.196-0.983 2.196-2.196v0c0-1.213-0.983-2.196-2.196-2.196s-2.196 0.983-2.196 2.196v0zM0 16c0 1.213 0.983 2.196 2.196 2.196s2.196-0.983 2.196-2.196v0c0-1.213-0.983-2.196-2.196-2.196s-2.196 0.983-2.196 2.196v0zM0 27.137c0 1.213 0.983 2.196 2.196 2.196s2.196-0.983 2.196-2.196v0c0-1.213-0.983-2.196-2.196-2.196s-2.196 0.983-2.196 2.196v0z"></path>
              </symbol>
                <symbol id="vditor-icon-up" viewBox="0 0 32 32">
                  <path d="M31.936 26.244l-14.846-20.466c-0.539-0.741-1.642-0.741-2.177 0l-14.85 20.466c-0.040 0.055-0.064 0.124-0.064 0.198 0 0.186 0.151 0.337 0.337 0.337 0 0 0.001 0 0.001 0h3.158c0.215 0 0.417-0.105 0.543-0.278l11.961-16.488 11.961 16.488c0.126 0.173 0.328 0.278 0.543 0.278h3.158c0.274 0 0.434-0.312 0.274-0.535z"></path>
                </symbol>
              </defs>
            </svg>\`);
        }
      `;
      document.head.appendChild(script);
    }

    const theme = RootStore.Get(UserStore).theme
    const vditor = new Vditor("vditor" + "-" + mode, {
      width: '100%',
      "toolbar": isPc ? ToolbarPC : ToolbarMobile,
      mode: store.viewMode === 'raw' ? 'sv' : store.viewMode,
      theme,
      hint: {
        extend: mode != 'comment' ? Extend : AIExtend
      },
      cdn: getBlinkoEndpoint('').replace(/\/$/, ""),
      async ctrlEnter(md) {
        await store.handleSend()
      },
      customWysiwygToolbar: (type: TWYSISYGToolbar, element: HTMLElement) => {
        console.log(type, element)
      },
      placeholder: t('i-have-a-new-idea'),
      i18n: {
        ...i18nEditor(t)
      },
      input: (value) => {
        onChange?.(value)
      },
      upload: {
        url: getBlinkoEndpoint('/api/file/upload'),
        success: (editor, res) => {
          const { fileName, filePath, type, size } = JSON.parse(res)
          store.handlePasteFile({
            fileName,
            filePath,
            type,
            size
          })
        },
        headers: {
          'Authorization': `Bearer ${RootStore.Get(UserStore).token}`
        },
        withCredentials: true,
        max: 1024 * 1024 * 1000,
        fieldName: 'file',
        multiple: false,
        linkToImgUrl: getBlinkoEndpoint('/api/file/upload-by-url'),
        linkToImgFormat(res) {
          const data = JSON.parse(res)
          const result = {
            msg: '',
            code: 0,
            data: {
              originalURL: data.originalURL,
              url: data.filePath,
            }
          }
          return JSON.stringify(result)
        }
      },
      tab: '\t',
      undoDelay: 20,
      value: content,
      toolbarConfig: {
        hide: !showToolbar,
      },
      preview: {
        hljs: {
          enable: true,
          style: theme === 'dark' ? 'github-dark' : 'github',
          lineNumber: true,
        },
        theme,
        delay: 20,
        math: {
          engine: 'MathJax',
        }
      },
      after: () => {
        vditor.setValue(content);
        store.init({
          onChange,
          onSend,
          mode,
          vditor
        });

        // Handle raw markdown mode (hide preview)
        if (store.viewMode === 'raw') {
          const previewElement = document.querySelector(`#vditor-${mode} .vditor-preview`);
          if (previewElement) {
            (previewElement as HTMLElement).style.display = 'none';
          }
        }

        isPc ? store.focus() : FocusEditorFixMobile()
      },
    });
    // Clear the effect
    return () => {
      store.vditor?.destroy();
      store.vditor = null;
    };

  }, [mode, blinko.config.value?.toolbarVisibility, store.viewMode, isPc]);

  useEffect(() => {
    store.references = originReference
    if (store.references.length > 0) {
      store.noteListByIds.call({ ids: store.references })
    }
  }, []);

  useEffect(() => {
    if (mode == 'create') {
      if (searchParams.get('path') == 'notes') {
        store.noteType = NoteType.NOTE
      } else if (searchParams.get('path') == 'todo') {
        store.noteType = NoteType.TODO
      } else {
        store.noteType = NoteType.BLINKO
      }
      if (searchParams.get('tagId')) {
        try {
          api.tags.fullTagNameById.query({ id: Number(searchParams.get('tagId')) }).then(res => {
            store.currentTagLabel = res
          })
        } catch (error) {
          console.error(error)
        }
      } else {
        store.currentTagLabel = ''
      }
    } else {
      store.noteType = toNoteTypeEnum(blinko.curSelectedNote?.type)
    }
  }, [mode, searchParams.get('path'), searchParams.get('tagId')]);
};


export const useEditorEvents = (store: EditorStore) => {
  const adjustEditorHeight = () => {
    if (!store.isFullscreen) return;

    requestAnimationFrame(() => {
      // Handle different editor modes
      let editorElement: HTMLElement | null = null;

      if (store.viewMode === 'ir') {
        editorElement = document.querySelector('.vditor-ir .vditor-reset') as HTMLElement;
      } else if (store.viewMode === 'sv' || store.viewMode === 'raw') {
        editorElement = document.querySelector('.vditor-sv .vditor-reset') as HTMLElement;
      } else if (store.viewMode === 'wysiwyg') {
        editorElement = document.querySelector('.vditor-wysiwyg .vditor-reset') as HTMLElement;
      }

      const attachmentContainer = document.querySelector('.attachment-container') as HTMLElement;
      const referenceContainer = document.querySelector('.reference-container') as HTMLElement;

      if (editorElement) {
        const attachmentHeight = attachmentContainer?.offsetHeight || 0;
        const referenceHeight = referenceContainer?.offsetHeight || 0;
        const toolbarHeight = 50;
        const padding = 40;

        const availableHeight = `calc(100vh - ${toolbarHeight + attachmentHeight + referenceHeight + padding}px)`;
        editorElement.style.height = availableHeight;
        editorElement.style.maxHeight = availableHeight;
      }
    });
  };

  useEffect(() => {
    if (store.isFullscreen) {
      adjustEditorHeight();
    }
  }, [store.files.length, store.references.length]);

  const handleFullScreen = (isFullscreen: boolean) => {
    store.setFullscreen(isFullscreen);
    if (isFullscreen) {
      adjustEditorHeight();
      const resizeObserver = new ResizeObserver(() => {
        requestAnimationFrame(adjustEditorHeight);
      });

      const attachmentContainer = document.querySelector('.attachment-container');
      const referenceContainer = document.querySelector('.reference-container');
      const editorContainer = document.querySelector('.vditor') as HTMLElement;

      if (attachmentContainer) resizeObserver.observe(attachmentContainer);
      if (referenceContainer) resizeObserver.observe(referenceContainer);
      if (editorContainer) resizeObserver.observe(editorContainer);

      (store as any)._resizeObserver = resizeObserver;

      const mutationObserver = new MutationObserver(() => {
        requestAnimationFrame(adjustEditorHeight);
      });

      if (attachmentContainer) {
        mutationObserver.observe(attachmentContainer, {
          childList: true,
          subtree: true,
          attributes: true
        });
      }
      if (referenceContainer) {
        mutationObserver.observe(referenceContainer, {
          childList: true,
          subtree: true,
          attributes: true
        });
      }

      (store as any)._mutationObserver = mutationObserver;
    } else {
      // Reset height for all editor modes
      const irElement = document.querySelector('.vditor-ir .vditor-reset') as HTMLElement;
      const svElement = document.querySelector('.vditor-sv .vditor-reset') as HTMLElement;
      const wysiwygElement = document.querySelector('.vditor-wysiwyg .vditor-reset') as HTMLElement;

      [irElement, svElement, wysiwygElement].forEach(element => {
        if (element) {
          element.style.height = '';
          element.style.maxHeight = '';
        }
      });
      if ((store as any)._resizeObserver) {
        (store as any)._resizeObserver.disconnect();
        (store as any)._resizeObserver = null;
      }
      if ((store as any)._mutationObserver) {
        (store as any)._mutationObserver.disconnect();
        (store as any)._mutationObserver = null;
      }
    }
  };

  useEffect(() => {
    eventBus.on('editor:clear', store.clearMarkdown);
    eventBus.on('editor:insert', store.insertMarkdown);
    eventBus.on('editor:replace', store.replaceMarkdown);
    eventBus.on('editor:focus', store.focus);
    eventBus.on('editor:setViewMode', (mode) => {
      store.viewMode = mode;

      // Handle preview visibility for raw mode
      const editorId = `vditor-${store.mode}`;
      const previewElement = document.querySelector(`#${editorId} .vditor-preview`);
      if (previewElement) {
        if (mode === 'raw') {
          (previewElement as HTMLElement).style.display = 'none';
        } else {
          (previewElement as HTMLElement).style.display = '';
        }
      }

      if (store.isFullscreen) {
        adjustEditorHeight();
      }
    });
    eventBus.on('editor:setFullScreen', handleFullScreen);
    store.handleIOSFocus();

    return () => {
      eventBus.off('editor:clear', store.clearMarkdown);
      eventBus.off('editor:insert', store.insertMarkdown);
      eventBus.off('editor:replace', store.replaceMarkdown);
      eventBus.off('editor:focus', store.focus);
      eventBus.off('editor:setViewMode', (mode) => {
        store.viewMode = mode;
      });
      eventBus.off('editor:setFullScreen', handleFullScreen);
      if ((store as any)._resizeObserver) {
        (store as any)._resizeObserver.disconnect();
        (store as any)._resizeObserver = null;
      }
      if ((store as any)._mutationObserver) {
        (store as any)._mutationObserver.disconnect();
        (store as any)._mutationObserver = null;
      }
    };
  }, []);
};

export const useEditorFiles = (
  store: EditorStore,
  blinko: BlinkoStore,
  originFiles?: any[],
) => {
  useEffect(() => {
    if (originFiles?.length) {
      console.log({ originFiles })
      store.files = HandleFileType(originFiles);
    }
  }, [originFiles]);
};

export const useEditorHeight = (
  onHeightChange: (() => void) | undefined,
  blinko: BlinkoStore,
  content: string,
  store: EditorStore
) => {
  useEffect(() => {
    onHeightChange?.();
  }, [store.noteType, content, store.files?.length, store.viewMode]);
}; 